package com.jml.api.controller;

import com.jml.datasource1.dao.UserMapperTest01;
import com.jml.datasource2.dao.UserMapperTest02;
import com.jml.datasource1.service.UserService001;
import com.jml.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

	@Autowired
	private UserMapperTest01 userMapperTest01;
	@Autowired
	private UserMapperTest02 userMapperTest02;
	@Autowired
	private UserService001 userService;

	@RequestMapping("/findByname")
	public User  findByname(){
		User byName = userMapperTest02.findByName("Tom2");
		return byName;
	}

	//清除缓存
	@Autowired
	private CacheManager cacheManager;
	@RequestMapping("/remoKey")
	public void remoKey() {
		cacheManager.getCache("baseCache").clear();
	}


	@RequestMapping("/data")
	public String  insert(){
		userMapperTest01.insert("qqqq",1);
		userMapperTest02.insert("www",1);
		return "success";
	}
	@RequestMapping("/trans")
	public String  trans(){
		userService.insert();
		return "success";
	}



	@RequestMapping("/asyn")
	public String  asyn(){
		System.out.println("111111111111111111111111111");
		userService.asyn();
		System.out.println("22222222222222222222222222222");
		return "success";
	}
}
